/*
 * Copyright 2011 Andrew Freer
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */
#include "resources.h"
#include "dxdiagcom.h"
#include "sound_tab.h"
#include "main_dialog.h"
#include "globals.h"
#include "utility.h"
#include <assert.h>
#include <string.h>
#include <commctrl.h>
#include <stdio.h>
#include <wchar.h>
#include <winuser.h>

VOID populate_sound_tab_labels(HWND hSoundTab);
VOID populate_sound_tab_values(HWND hSoundTab);
VOID set_HSAL_slider(HWND hSoundTab, long value);
VOID set_HSAL_slider_label(HWND hSoundTab, long value);
long get_HSAL_slider(HWND hSoundTab);
VOID set_HSAL_invalid(HWND soundTab);
VOID set_HSAL_current(HWND soundTab);

INT_PTR CALLBACK sound_tab_dlg_proc(HWND hwnd, UINT message, WPARAM wParam,
                                    LPARAM lParam)
{
    HWND handle;
    long sliderPos;
    SoundTabContext *context = (SoundTabContext *) GetWindowLongW(hwnd,
                                                                  GWL_USERDATA);
    switch (message) {
    case WM_HSCROLL:
        handle = GetDlgItem(hwnd, DLG_SND_DIRX_SLIDER);
        if ((HANDLE) lParam == handle) {
            switch (LOWORD(wParam)) {
            case TB_ENDTRACK:
                /*
                 * This prevents errors due to a spurious TB_ENDTRACK message.
                 * Suspect WM_CAPTURECHANGED is generating the duplicate upon
                 * MessageBox open.
                 */
                if (!context->handlingHSALChange) {
                    /* Disallow changes in HSAL */
                    sliderPos = get_HSAL_slider(hwnd);
                    if (sliderPos != context->accelerationLevel) {
                        context->handlingHSALChange = TRUE;
                        wine_fixme_resource(STRING_DLG_SND_HSAL_ERROR);
                        set_HSAL_slider(hwnd, context->accelerationLevel);
                        context->handlingHSALChange = FALSE;
                    }
                }
                break;
            case TB_THUMBPOSITION:
                break;
            default:
                sliderPos = get_HSAL_slider(hwnd);
                set_HSAL_slider_label(hwnd, sliderPos);
                break;
            }
        } else {
            return FALSE;
        }
        break;
    case WM_CAPTURECHANGED:
        printf("WM_CAPTURECHANGED");
        break;
    case WM_COMMAND:
        switch (LOWORD(wParam)) {
        case DLG_SND_DIRX_BTN:
            wine_fixme_resource(STRING_COMMON_NOT_IMPLEMENTED);
            break;
        }
    default:
        return FALSE;
    }
    return TRUE;
}

VOID create_sound_tab(Tab * tab, DxDiag_SoundDevice * soundDevice)
{
    HWND hSoundTabDialog;
    SoundTabContext *soundTabContext;

    /* Create sound dialog */
    soundTabContext = malloc(sizeof(SoundTabContext));
    soundTabContext->soundDevice = soundDevice;
    soundTabContext->handlingHSALChange = FALSE;
    hSoundTabDialog =
        CreateDialogW(g_hinstance, MAKEINTRESOURCEW(DLG_SOUND),
                      g_hmaindialog, sound_tab_dlg_proc);
    if (hSoundTabDialog == NULL) {
        MessageBoxA(g_hmaindialog, "Sound tab could not be created",
                    "Fatal error", MB_OK | MB_ICONINFORMATION);
    }

    tab_initialize(tab, hSoundTabDialog, resize_sound_tab);
    SetWindowLongW(hSoundTabDialog, GWL_USERDATA, (LONG) soundTabContext);

    /* Populate strings and resize */
    populate_sound_tab_labels(hSoundTabDialog);
    populate_sound_tab_values(hSoundTabDialog);
}

VOID resize_sound_tab(HWND hSoundTab, RECT tabDisplayArea)
{
    HANDLE handle;
    RECT dlus;
    LONG tabWidth, tabHeight;

    /* Relative positioning */
    LONG devGbLeft, devGbWidth, devGbTop, devGbHeight;
    LONG drvGbLeft, drvGbWidth, drvGbTop, drvGbHeight;
    LONG dirxGbLeft, dirxGbWidth, dirxGbTop, dirxGbHeight;
    LONG notesGbLeft, notesGbWidth, notesGbTop, notesGbHeight;
    LONG devLabLeft, devLabWidth, devLabTop, devLabHeight;
    LONG devValLeft, devValWidth;
    LONG drvLabLeft, drvLabWidth, drvLabTop, drvLabHeight;
    LONG drvValLeft, drvValWidth;
    LONG dirxMidy;
    LONG dirxHsalLeft, dirxHsalTop, dirxHsalWidth, dirxHsalHeight;
    LONG dirxSliderLeft, dirxSliderTop, dirxSliderWidth, dirxSliderHeight;
    LONG dirxBaTop;
    LONG dirxBtnLeft, dirxBtnWidth, dirxBtnTop, dirxBtnHeight;
    LONG notesLeft, notesTop, notesWidth, notesHeight;

    /* Tab width/height */
    tabWidth = tabDisplayArea.right - tabDisplayArea.left;
    tabHeight = tabDisplayArea.bottom - tabDisplayArea.top;

    /* Get dialog units */
    dlus.left = 0;
    dlus.right = DLG_UNIT_DEF_WIDTH;
    dlus.top = 0;
    dlus.bottom = DLG_UNIT_DEF_HEIGHT;
    MapDialogRect(hSoundTab, &dlus);

    /* Set dialog size */
    SetWindowPos(hSoundTab, NULL, tabDisplayArea.left, tabDisplayArea.top,
                 tabWidth, tabHeight, 0);

    /* Device groupbox */
    handle = GetDlgItem(hSoundTab, DLG_SND_DEV_GB);
    devGbLeft = WND_DEF_SPACING;
    devGbTop = WND_DEF_SPACING;
    devGbWidth = tabWidth / 2;
    devGbHeight = tabHeight * 1 / 2;
    SetWindowPos(handle, NULL, devGbLeft, devGbTop, devGbWidth,
                 devGbHeight, 0);

    /* Drivers groupbox */
    handle = GetDlgItem(hSoundTab, DLG_SND_DRV_GB);
    drvGbLeft = devGbLeft + devGbWidth + WND_DEF_SPACING;
    drvGbTop = WND_DEF_SPACING;
    drvGbWidth = tabWidth - drvGbLeft - WND_DEF_SPACING;
    drvGbHeight = devGbHeight;
    SetWindowPos(handle, NULL, drvGbLeft, drvGbTop, drvGbWidth,
                 drvGbHeight, 0);

    /* DirectX groupbox */
    handle = GetDlgItem(hSoundTab, DLG_SND_DIRX_GB);
    dirxGbLeft = WND_DEF_SPACING;
    dirxGbTop = devGbTop + devGbHeight + WND_DEF_SPACING;
    dirxGbWidth = tabWidth - 2 * WND_DEF_SPACING;
    dirxGbHeight = tabHeight * 1 / 4;
    SetWindowPos(handle, NULL, dirxGbLeft, dirxGbTop, dirxGbWidth,
                 dirxGbHeight, 0);

    /* Notes groupbox */
    handle = GetDlgItem(hSoundTab, DLG_SND_NOTES_GB);
    notesGbLeft = WND_DEF_SPACING;
    notesGbTop = dirxGbTop + dirxGbHeight + WND_DEF_SPACING;
    notesGbWidth = dirxGbWidth;
    notesGbHeight = tabHeight - notesGbTop - WND_DEF_SPACING;
    SetWindowPos(handle, NULL, notesGbLeft, notesGbTop, notesGbWidth,
                 notesGbHeight, 0);

    /* Device labels */
    devLabLeft = devGbLeft + WND_DEF_SPACING;
    devLabWidth = 20 * dlus.right;
    devLabHeight = dlus.bottom;
    devValLeft = devLabLeft + devLabWidth + WND_DEF_SPACING;
    devValWidth = devGbLeft + devGbWidth - devValLeft - WND_DEF_SPACING;

    /* Device name */
    devLabTop = devGbTop + dlus.bottom * 1.5;
    handle = GetDlgItem(hSoundTab, DLG_SND_DEV_NAME_LBL);
    SetWindowPos(handle, NULL, devLabLeft, devLabTop, devLabWidth,
                 devLabHeight, 0);
    handle = GetDlgItem(hSoundTab, DLG_SND_DEV_NAME);
    SetWindowPos(handle, NULL, devValLeft, devLabTop, devValWidth,
                 devLabHeight, 0);

    /* Device device id */
    devLabTop = devLabTop + dlus.bottom * 1.5;
    handle = GetDlgItem(hSoundTab, DLG_SND_DEV_DEV_ID_LBL);
    SetWindowPos(handle, NULL, devLabLeft, devLabTop, devLabWidth,
                 devLabHeight, 0);
    handle = GetDlgItem(hSoundTab, DLG_SND_DEV_DEV_ID);
    SetWindowPos(handle, NULL, devValLeft, devLabTop, devValWidth,
                 devLabHeight, 0);

    /* Device man id */
    devLabTop = devLabTop + dlus.bottom * 1.5;
    handle = GetDlgItem(hSoundTab, DLG_SND_DEV_MANID_LBL);
    SetWindowPos(handle, NULL, devLabLeft, devLabTop, devLabWidth,
                 devLabHeight, 0);
    handle = GetDlgItem(hSoundTab, DLG_SND_DEV_MANID);
    SetWindowPos(handle, NULL, devValLeft, devLabTop, devValWidth,
                 devLabHeight, 0);

    /* Device prod id */
    devLabTop = devLabTop + dlus.bottom * 1.5;
    handle = GetDlgItem(hSoundTab, DLG_SND_DEV_PRODID_LBL);
    SetWindowPos(handle, NULL, devLabLeft, devLabTop, devLabWidth,
                 devLabHeight, 0);
    handle = GetDlgItem(hSoundTab, DLG_SND_DEV_PRODID);
    SetWindowPos(handle, NULL, devValLeft, devLabTop, devValWidth,
                 devLabHeight, 0);

    /* Device type */
    devLabTop = devLabTop + dlus.bottom * 1.5;
    handle = GetDlgItem(hSoundTab, DLG_SND_DEV_TYPE_LBL);
    SetWindowPos(handle, NULL, devLabLeft, devLabTop, devLabWidth,
                 devLabHeight, 0);
    handle = GetDlgItem(hSoundTab, DLG_SND_DEV_TYPE);
    SetWindowPos(handle, NULL, devValLeft, devLabTop, devValWidth,
                 devLabHeight, 0);

    /* Device def */
    devLabTop = devLabTop + dlus.bottom * 1.5;
    handle = GetDlgItem(hSoundTab, DLG_SND_DEV_DEF_LBL);
    SetWindowPos(handle, NULL, devLabLeft, devLabTop, devLabWidth,
                 devLabHeight, 0);
    handle = GetDlgItem(hSoundTab, DLG_SND_DEV_DEF);
    SetWindowPos(handle, NULL, devValLeft, devLabTop, devValWidth,
                 devLabHeight, 0);

    /* Driver labels */
    drvLabLeft = drvGbLeft + WND_DEF_SPACING;
    drvLabWidth = 15 * dlus.right;
    drvLabHeight = dlus.bottom;
    drvValLeft = drvLabLeft + drvLabWidth + WND_DEF_SPACING;
    drvValWidth = drvGbLeft + drvGbWidth - drvValLeft - WND_DEF_SPACING;

    /* Driver name */
    drvLabTop = drvGbTop + dlus.bottom * 1.5;
    handle = GetDlgItem(hSoundTab, DLG_SND_DRV_NAME_LBL);
    SetWindowPos(handle, NULL, drvLabLeft, drvLabTop, drvLabWidth,
                 drvLabHeight, 0);
    handle = GetDlgItem(hSoundTab, DLG_SND_DRV_NAME);
    SetWindowPos(handle, NULL, drvValLeft, drvLabTop, drvValWidth,
                 drvLabHeight, 0);

    /* Driver version */
    drvLabTop = drvLabTop + dlus.bottom * 1.5;
    handle = GetDlgItem(hSoundTab, DLG_SND_DRV_VER_LBL);
    SetWindowPos(handle, NULL, drvLabLeft, drvLabTop, drvLabWidth,
                 drvLabHeight, 0);
    handle = GetDlgItem(hSoundTab, DLG_SND_DRV_VER);
    SetWindowPos(handle, NULL, drvValLeft, drvLabTop, drvValWidth,
                 drvLabHeight, 0);

    /* Driver date */
    drvLabTop = drvLabTop + dlus.bottom * 1.5;
    handle = GetDlgItem(hSoundTab, DLG_SND_DRV_DATE_LBL);
    SetWindowPos(handle, NULL, drvLabLeft, drvLabTop, drvLabWidth,
                 drvLabHeight, 0);
    handle = GetDlgItem(hSoundTab, DLG_SND_DRV_DATE);
    SetWindowPos(handle, NULL, drvValLeft, drvLabTop, drvValWidth,
                 drvLabHeight, 0);

    /* Driver whql */
    drvLabTop = drvLabTop + dlus.bottom * 1.5;
    handle = GetDlgItem(hSoundTab, DLG_SND_DRV_WHQL_LBL);
    SetWindowPos(handle, NULL, drvLabLeft, drvLabTop, drvLabWidth,
                 drvLabHeight, 0);
    handle = GetDlgItem(hSoundTab, DLG_SND_DRV_WHQL);
    SetWindowPos(handle, NULL, drvValLeft, drvLabTop, drvValWidth,
                 drvLabHeight, 0);

    /* Driver other files */
    drvLabTop = drvLabTop + dlus.bottom * 1.5;
    handle = GetDlgItem(hSoundTab, DLG_SND_DRV_OTHER_LBL);
    SetWindowPos(handle, NULL, drvLabLeft, drvLabTop, drvLabWidth,
                 drvLabHeight, 0);
    handle = GetDlgItem(hSoundTab, DLG_SND_DRV_OTHER);
    SetWindowPos(handle, NULL, drvValLeft, drvLabTop, drvValWidth,
                 drvLabHeight, 0);

    /* Driver provider */
    drvLabTop = drvLabTop + dlus.bottom * 1.5;
    handle = GetDlgItem(hSoundTab, DLG_SND_DRV_PRV_LBL);
    SetWindowPos(handle, NULL, drvLabLeft, drvLabTop, drvLabWidth,
                 drvLabHeight, 0);
    handle = GetDlgItem(hSoundTab, DLG_SND_DRV_PRV);
    SetWindowPos(handle, NULL, drvValLeft, drvLabTop, drvValWidth,
                 drvLabHeight, 0);

    /* DirectX Groupbox */
    dirxMidy = dirxGbTop + dirxGbHeight / 2;
    dirxHsalHeight = 2 * dlus.bottom;
    dirxHsalTop = dirxMidy - dirxHsalHeight / 2;
    dirxHsalLeft = dirxGbLeft + WND_DEF_SPACING;
    dirxHsalWidth = tabWidth / 6;
    dirxSliderHeight = 3 * dlus.bottom;
    dirxSliderTop = dirxMidy - dlus.bottom;
    dirxSliderWidth = (100 * dlus.right) / DLG_UNIT_DEF_WIDTH;
    dirxSliderLeft = dirxHsalLeft + dirxHsalWidth + WND_DEF_SPACING;
    dirxBaTop = dirxSliderTop - dlus.bottom;
    dirxBtnWidth =
        (DLG_MAIN_BUTTON_WIDTH / DLG_UNIT_DEF_WIDTH) * dlus.right;
    dirxBtnHeight =
        (BUTTON_DEF_HEIGHT * dlus.bottom) / DLG_UNIT_DEF_HEIGHT;
    dirxBtnLeft =
        dirxGbLeft + dirxGbWidth - (dirxHsalLeft + dirxHsalWidth -
                                    dirxGbLeft) - (dirxBtnWidth / 2);
    dirxBtnTop = dirxMidy - dirxBtnHeight / 2;

    /* Slider */
    handle = GetDlgItem(hSoundTab, DLG_SND_DIRX_SLIDER);
    SetWindowPos(handle, NULL, dirxSliderLeft, dirxSliderTop,
                 dirxSliderWidth, dirxSliderHeight, 0);
    SendMessageW(handle, TBM_SETRANGE, TRUE,
                 MAKELPARAM(DLG_SND_ACCLEVELMIN, DLG_SND_ACCLEVELMAX));

    /* Hardware acceleration label */
    handle = GetDlgItem(hSoundTab, DLG_SND_DIRX_HSAL_LBL);
    SetWindowPos(handle, NULL, dirxHsalLeft, dirxHsalTop, dirxHsalWidth,
                 dirxHsalHeight, 0);

    /* Current acceleration label */
    handle = GetDlgItem(hSoundTab, DLG_SND_DIRX_BA_LBL);
    SetWindowPos(handle, NULL, dirxSliderLeft, dirxBaTop, dirxSliderWidth,
                 dlus.bottom, 0);

    /* Test DirectSound button */
    handle = GetDlgItem(hSoundTab, DLG_SND_DIRX_BTN);
    SetWindowPos(handle, NULL, dirxBtnLeft, dirxBtnTop, dirxBtnWidth,
                 dirxBtnHeight, 0);

    /* Notes groupbox */
    notesLeft = notesGbLeft + WND_DEF_SPACING;
    notesTop = notesGbTop + 1.5 * dlus.bottom;
    notesWidth = notesGbLeft + notesGbWidth - notesLeft - WND_DEF_SPACING;
    notesHeight =
        notesGbHeight - (notesTop - notesGbTop) - WND_DEF_SPACING;
    handle = GetDlgItem(hSoundTab, DLG_SND_NOTES);
    SetWindowPos(handle, NULL, notesLeft, notesTop, notesWidth,
                 notesHeight, 0);
}

VOID populate_sound_tab_values(HWND hSoundTabDialog)
{
    SoundTabContext *soundTabContext;
    DxDiag_SoundDevice *soundDevice;
    const WCHAR *dVersion, *dLanguage;
    static WCHAR formatW[] = { '%', 's', ' ', '(', '%', 's', ')', '\0' };

    /* Set up sound tab context */
    soundTabContext = (SoundTabContext *) GetWindowLongW(hSoundTabDialog,
                                                         GWL_USERDATA);
    soundDevice = soundTabContext->soundDevice;

    /* Device information */
    set_control_text(hSoundTabDialog, (WCHAR *) soundDevice->szDescription,
                     DLG_SND_DEV_NAME);
    set_control_text(hSoundTabDialog, (WCHAR *) soundDevice->szHardwareID,
                     DLG_SND_DEV_DEV_ID);
    set_control_text(hSoundTabDialog,
                     (WCHAR *) soundDevice->szManufacturerID,
                     DLG_SND_DEV_MANID);
    set_control_text(hSoundTabDialog, (WCHAR *) soundDevice->szProductID,
                     DLG_SND_DEV_PRODID);
    set_control_text(hSoundTabDialog, (WCHAR *) soundDevice->szType,
                     DLG_SND_DEV_TYPE);
    set_control_text(hSoundTabDialog,
                     (WCHAR *) soundDevice->bDefaultSoundPlayback,
                     DLG_SND_DEV_DEF);

    /* Driver information */
    set_control_text(hSoundTabDialog, (WCHAR *) soundDevice->szDriverName,
                     DLG_SND_DRV_NAME);
    dVersion = get_safe_string(soundDevice->szDriverVersion);
    dLanguage = get_safe_string(soundDevice->szDriverLanguageLocalized);
    {
        WCHAR text[lstrlenW(dVersion)+lstrlenW(dLanguage)+3+1];
        wsprintfW(text, formatW, dVersion, dLanguage);
        set_control_text(hSoundTabDialog, text, DLG_SND_DRV_VER);
    }
    set_control_text(hSoundTabDialog,
                     (WCHAR *) soundDevice->szDriverDateLocalized,
                     DLG_SND_DRV_DATE);
    set_control_text(hSoundTabDialog, (WCHAR *) soundDevice->bDriverSigned,
                     DLG_SND_DRV_WHQL);
    set_control_text(hSoundTabDialog,
                     (WCHAR *) soundDevice->szOtherDrivers,
                     DLG_SND_DRV_OTHER);
    set_control_text(hSoundTabDialog, (WCHAR *) soundDevice->szProvider,
                     DLG_SND_DRV_PRV);

    /* Hardware acceleration level */
    if (soundDevice->lAccelerationLevel == NULL) {
        set_HSAL_invalid(hSoundTabDialog);
    }
    soundTabContext->accelerationLevel =
        lstrtolW((WCHAR *) soundDevice->lAccelerationLevel, NULL, 10);
    if (soundTabContext->accelerationLevel < DLG_SND_ACCLEVELMIN
        || soundTabContext->accelerationLevel > DLG_SND_ACCLEVELMAX) {
        set_HSAL_invalid(hSoundTabDialog);
    } else {
        set_HSAL_slider(hSoundTabDialog,
                        soundTabContext->accelerationLevel);
    }

    /* Notes information */
    set_control_text(hSoundTabDialog,
                     (WCHAR *) soundDevice->szNotesLocalized,
                     DLG_SND_NOTES);
}

VOID set_HSAL_invalid(HWND soundTab)
{
    HWND handle;
    handle = GetDlgItem(soundTab, DLG_SND_DIRX_SLIDER);
    ShowWindow(handle, SW_HIDE);
    SendMessageW(handle, TBM_SETPOS, TRUE, 0);
    set_control_text_resource(soundTab, (STRING_DLG_SND_ACCINVALID),
                              DLG_SND_DIRX_BA_LBL);
}

long get_HSAL_slider(HWND hSoundTabDialog)
{
    long value;
    HWND handle;
    handle = GetDlgItem(hSoundTabDialog, DLG_SND_DIRX_SLIDER);
    value = SendMessageW(handle, TBM_GETPOS, 0, 0);
    return value;
}

VOID set_HSAL_slider(HWND hSoundTabDialog, long value)
{
    HWND handle;
    handle = GetDlgItem(hSoundTabDialog, DLG_SND_DIRX_SLIDER);
    SendMessageW(handle, TBM_SETPOS, TRUE, (LPARAM) value);
    set_HSAL_slider_label(hSoundTabDialog, value);
}

VOID set_HSAL_slider_label(HWND hSoundTabDialog, long value)
{
    set_control_text_resource(hSoundTabDialog, (STRING_DLG_SND_ACC1
                                                + (int) value),
                              DLG_SND_DIRX_BA_LBL);
}

VOID populate_sound_tab_labels(HWND hSoundTabDialog)
{
    /* Groupboxes */
    set_control_text_resource(hSoundTabDialog, STRING_DLG_SND_DEV_GB,
                              DLG_SND_DEV_GB);
    set_control_text_resource(hSoundTabDialog, STRING_DLG_SND_DRV_GB,
                              DLG_SND_DRV_GB);
    set_control_text_resource(hSoundTabDialog, STRING_DLG_SND_DIRX_GB,
                              DLG_SND_DIRX_GB);
    set_control_text_resource(hSoundTabDialog, STRING_NOTES,
                              DLG_SND_NOTES_GB);

    /* Device labels */
    set_control_text_resource(hSoundTabDialog, STRING_DLG_SND_DEV_NAME,
                              DLG_SND_DEV_NAME_LBL);
    set_control_text_resource(hSoundTabDialog,
                              STRING_DLG_SND_DEV_DEVID,
                              DLG_SND_DEV_DEV_ID_LBL);
    set_control_text_resource(hSoundTabDialog, STRING_DLG_SND_DEV_MANID,
                              DLG_SND_DEV_MANID_LBL);
    set_control_text_resource(hSoundTabDialog, STRING_DLG_SND_DEV_PRDID,
                              DLG_SND_DEV_PRODID_LBL);
    set_control_text_resource(hSoundTabDialog, STRING_DLG_SND_DEV_TYPE,
                              DLG_SND_DEV_TYPE_LBL);
    set_control_text_resource(hSoundTabDialog, STRING_DLG_SND_DEV_DEF,
                              DLG_SND_DEV_DEF_LBL);

    /* Drivers labels */
    set_control_text_resource(hSoundTabDialog, STRING_DLG_SND_DRV_NAME,
                              DLG_SND_DRV_NAME_LBL);
    set_control_text_resource(hSoundTabDialog, STRING_DLG_SND_DRV_VER,
                              DLG_SND_DRV_VER_LBL);
    set_control_text_resource(hSoundTabDialog, STRING_DLG_SND_DRV_DATE,
                              DLG_SND_DRV_DATE_LBL);
    set_control_text_resource(hSoundTabDialog, STRING_DLG_SND_DRV_WHQL,
                              DLG_SND_DRV_WHQL_LBL);
    set_control_text_resource(hSoundTabDialog,
                              STRING_DLG_SND_DRV_OTHER,
                              DLG_SND_DRV_OTHER_LBL);
    set_control_text_resource(hSoundTabDialog, STRING_DLG_SND_DRV_PROV,
                              DLG_SND_DRV_PRV_LBL);

    /* Other labels */
    set_control_text_resource(hSoundTabDialog,
                              STRING_DLG_SND_ACCLEVELS,
                              DLG_SND_DIRX_HSAL_LBL);
    set_control_text_resource(hSoundTabDialog, STRING_DLG_SND_TEST,
                              DLG_SND_DIRX_BTN);
}
